/*
 * @Author: chen haoxuan
 * @Date: 2021-05-23 22:51:55
 * @LastEditTime: 2021-05-23 23:07:01
 */
// 后置自增
#include<iostream>
using namespace std;
class Time
{
    public:
        Time(){minute=0;sec=0;};
        Time(int m,int s):minute(m),sec(s){};
        Time operator ++ ();    // 声明前置自增运算符 ++ 重载函数
        Time operator ++ (int); // 声明后置自增运算符 ++ 重载函数
        void display();
    private:
        int minute;
        int sec;
};
Time Time::operator ++ ()
{
    if (++sec>=60)
    {
        sec-=60;
        ++minute;
    }
    return *this;
}
Time Time::operator ++ (int)
{
    Time temp(*this);   //建立临时对象
    sec++;
    if (sec>=60)
    {
        sec-=60;
        ++minute;
    }
    return *this;
}
void Time::display()
{
    cout<<minute<<":"<<sec<<endl;
}
int main()
{
    Time time1(34,59),time2;
    cout<<"time1 : ";
    time1.display();
    time1++;
    cout<<"++time1: ";
    time1.display();
    time2=time1++;
    cout<<"time1++ :";
    time2.display();
    cout<<" time2 : ";
    time2.display();
    system("pause");
    return 0;
}